﻿using System;
using System.Windows.Forms;
using KZ.Exception;
using KZ.Lottery.BLL;
using KZ.Lottery.Resources;
using KZ.Utilities;
using KZ.Lottery.DAL;
using KZ.Lottery.Entities;

namespace KZ.Lottery
{
    public partial class FrmDashboard : Form
    {
        public FrmDashboard()
        {
            InitializeComponent();
        }

        private void FrmDashboard_Load(object sender, EventArgs e)
        {
            LoadRevenue();
        }

        private void LoadRevenue()
        {
            try
            {
                DateTime? from;
                DateTime? to;
                RuleDetailGroupReportBLL.GetFirstDateLastDate(out from, out to);

                txtLastRevenue.Text = Utility.CurrencyParse(ReportBLL.GetReportForRevenue(to), Global.Culture);
                
                Setting setting = SettingDAL.GetSetting(KZ_Resource.Setting_Revenue);
                txtRevenue.Text = Utility.CurrencyParse(Utility.DecimalParse(setting.SettingValue), Global.Culture);
            }
            catch (DataAccessException ex)
            {
                Global.SetMessage(lblMessage, ex.Message, false);
            }
            catch (System.Exception ex)
            {
                Log.LogEx("LoadRevenue", ex);
                Global.SetMessage(lblMessage, KZ_Message.BLM_ERR_GENERAL, false);
            }
        }
    }
}